/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author victor.silva
 */
@Entity
@Table(name = "questionario")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Questionario.findAll", query = "SELECT q FROM Questionario q"),
    @NamedQuery(name = "Questionario.findByIdquestionario", query = "SELECT q FROM Questionario q WHERE q.idquestionario = :idquestionario"),
    @NamedQuery(name = "Questionario.findByDatapublicacao", query = "SELECT q FROM Questionario q WHERE q.datapublicacao = :datapublicacao"),
    @NamedQuery(name = "Questionario.findByDatacriacao", query = "SELECT q FROM Questionario q WHERE q.datacriacao = :datacriacao"),
    @NamedQuery(name = "Questionario.findByAtivo", query = "SELECT q FROM Questionario q WHERE q.ativo = :ativo")})
public class Questionario implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idquestionario")
    private Integer idquestionario;
    @Column(name = "datapublicacao")
    @Temporal(TemporalType.DATE)
    private Date datapublicacao;
    @Column(name = "datacriacao")
    @Temporal(TemporalType.DATE)
    private Date datacriacao;
    @Column(name = "ativo")
    private Boolean ativo;
    @JoinColumns({
        @JoinColumn(name = "turma_prdltv_prdletivo", referencedColumnName = "prdltv_prdletivo"),
        @JoinColumn(name = "turma_crs_codigo", referencedColumnName = "crs_codigo"),
        @JoinColumn(name = "turma_dsc_codigo", referencedColumnName = "dsc_codigo"),
        @JoinColumn(name = "turma_trmcbc_serie", referencedColumnName = "trmcbc_serie"),
        @JoinColumn(name = "turma_trmcbc_sequencia", referencedColumnName = "trmcbc_sequencia"),
        @JoinColumn(name = "turma_trm_codigo", referencedColumnName = "trm_codigo")})
    @ManyToOne(optional = false)
    private Turma turma;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "questionario")
    private List<QuestionarioHasQuestao> questionarioHasQuestaoList;

    public Questionario() {
    }

    public Questionario(Integer idquestionario) {
        this.idquestionario = idquestionario;
    }

    public Integer getIdquestionario() {
        return idquestionario;
    }

    public void setIdquestionario(Integer idquestionario) {
        this.idquestionario = idquestionario;
    }

    public Date getDatapublicacao() {
        return datapublicacao;
    }

    public void setDatapublicacao(Date datapublicacao) {
        this.datapublicacao = datapublicacao;
    }

    public Date getDatacriacao() {
        return datacriacao;
    }

    public void setDatacriacao(Date datacriacao) {
        this.datacriacao = datacriacao;
    }

    public Boolean getAtivo() {
        return ativo;
    }

    public void setAtivo(Boolean ativo) {
        this.ativo = ativo;
    }

    public Turma getTurma() {
        return turma;
    }

    public void setTurma(Turma turma) {
        this.turma = turma;
    }

    @XmlTransient
    public List<QuestionarioHasQuestao> getQuestionarioHasQuestaoList() {
        return questionarioHasQuestaoList;
    }

    public void setQuestionarioHasQuestaoList(List<QuestionarioHasQuestao> questionarioHasQuestaoList) {
        this.questionarioHasQuestaoList = questionarioHasQuestaoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idquestionario != null ? idquestionario.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Questionario)) {
            return false;
        }
        Questionario other = (Questionario) object;
        if ((this.idquestionario == null && other.idquestionario != null) || (this.idquestionario != null && !this.idquestionario.equals(other.idquestionario))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Questionario[ idquestionario=" + idquestionario + " ]";
    }
    
}
